package net.dntuan.simple.web.listener;

import javax.servlet.ServletContextAttributeEvent;
import javax.servlet.ServletContextAttributeListener;

import org.apache.log4j.Logger;

/**
 * @author tuan.dang
 *
 * <br>$LastChangedRevision: 37 $
 * <br>$LastChangedDate: 2014-04-07 16:55:59 +0000 (Mon, 07 Apr 2014) $
 */
public class MyServletContextAttributeListener implements ServletContextAttributeListener {

	private static final Logger LOGGER = Logger.getLogger(MyServletContextAttributeListener.class);

	public MyServletContextAttributeListener() {
		LOGGER.info("initialize");
	}

	@Override
	public void attributeAdded(ServletContextAttributeEvent scab) {
		LOGGER.info("add new attribute");
		LOGGER.info("access to context param: " + scab.getServletContext().getInitParameter("contact"));
		LOGGER.info(scab.getName() + ": " + scab.getValue());

	}

	@Override
	public void attributeRemoved(ServletContextAttributeEvent scab) {
		LOGGER.info("remove an attribute");
		LOGGER.info(scab.getName() + ": " + scab.getValue());
	}

	@Override
	public void attributeReplaced(ServletContextAttributeEvent scab) {
		LOGGER.info("replace value of attribute");
		LOGGER.info(scab.getName() + ": " + scab.getValue());
	}

}
